home *** CD-ROM | disk | FTP | other *** search
- package sun.print;
-
- import java.awt.Component;
- import java.awt.GridBagConstraints;
- import java.awt.GridBagLayout;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.ItemEvent;
- import java.awt.event.ItemListener;
- import java.io.FilePermission;
- import java.net.URI;
- import java.net.URISyntaxException;
- import javax.print.ServiceUIFactory;
- import javax.print.attribute.PrintServiceAttribute;
- import javax.print.attribute.standard.Destination;
- import javax.print.attribute.standard.PrinterInfo;
- import javax.print.attribute.standard.PrinterIsAcceptingJobs;
- import javax.print.attribute.standard.PrinterMakeAndModel;
- import javax.swing.BorderFactory;
- import javax.swing.JButton;
- import javax.swing.JCheckBox;
- import javax.swing.JComboBox;
- import javax.swing.JDialog;
- import javax.swing.JLabel;
- import javax.swing.JPanel;
- import javax.swing.event.PopupMenuEvent;
- import javax.swing.event.PopupMenuListener;
-
- class ServiceDialog$PrintServicePanel extends JPanel implements ActionListener, ItemListener, PopupMenuListener {
- private final String strTitle;
- private FilePermission printToFilePermission;
- private JButton btnProperties;
- private JCheckBox cbPrintToFile;
- private JComboBox cbName;
- private JLabel lblType;
- private JLabel lblStatus;
- private JLabel lblInfo;
- private ServiceUIFactory uiFactory;
- private boolean changedService;
- private boolean filePermission;
- // $FF: synthetic field
- final ServiceDialog this$0;
-
- public ServiceDialog$PrintServicePanel(ServiceDialog var1) {
- this.this$0 = var1;
- this.strTitle = ServiceDialog.getMsg("border.printservice");
- this.changedService = false;
- this.uiFactory = ServiceDialog.access$400(var1).getServiceUIFactory();
- GridBagLayout var2 = new GridBagLayout();
- GridBagConstraints var3 = new GridBagConstraints();
- this.setLayout(var2);
- this.setBorder(BorderFactory.createTitledBorder(this.strTitle));
- String[] var4 = new String[ServiceDialog.access$500(var1).length];
-
- for(int var5 = 0; var5 < var4.length; ++var5) {
- var4[var5] = ServiceDialog.access$500(var1)[var5].getName();
- }
-
- this.cbName = new JComboBox(var4);
- this.cbName.setSelectedIndex(ServiceDialog.access$600(var1));
- this.cbName.addItemListener(this);
- this.cbName.addPopupMenuListener(this);
- var3.fill = 1;
- var3.insets = ServiceDialog.access$700();
- var3.weightx = (double)0.0F;
- JLabel var6 = new JLabel(ServiceDialog.getMsg("label.psname"), 11);
- var6.setDisplayedMnemonic(ServiceDialog.access$800("label.psname"));
- var6.setLabelFor(this.cbName);
- ServiceDialog.access$300(var6, this, var2, var3);
- var3.weightx = (double)1.0F;
- var3.gridwidth = -1;
- ServiceDialog.access$300(this.cbName, this, var2, var3);
- var3.weightx = (double)0.0F;
- var3.gridwidth = 0;
- this.btnProperties = ServiceDialog.access$900("button.properties", this);
- ServiceDialog.access$300(this.btnProperties, this, var2, var3);
- var3.weighty = (double)1.0F;
- this.lblStatus = this.addLabel(ServiceDialog.getMsg("label.status"), var2, var3);
- this.lblStatus.setLabelFor((Component)null);
- this.lblType = this.addLabel(ServiceDialog.getMsg("label.pstype"), var2, var3);
- this.lblType.setLabelFor((Component)null);
- var3.gridwidth = 1;
- ServiceDialog.access$300(new JLabel(ServiceDialog.getMsg("label.info"), 11), this, var2, var3);
- var3.gridwidth = -1;
- this.lblInfo = new JLabel();
- this.lblInfo.setLabelFor((Component)null);
- ServiceDialog.access$300(this.lblInfo, this, var2, var3);
- var3.gridwidth = 0;
- this.cbPrintToFile = ServiceDialog.access$1000("checkbox.printtofile", this);
- ServiceDialog.access$300(this.cbPrintToFile, this, var2, var3);
- this.filePermission = this.allowedToPrintToFile();
- }
-
- public boolean isPrintToFileSelected() {
- return this.cbPrintToFile.isSelected();
- }
-
- private JLabel addLabel(String var1, GridBagLayout var2, GridBagConstraints var3) {
- var3.gridwidth = 1;
- ServiceDialog.access$300(new JLabel(var1, 11), this, var2, var3);
- var3.gridwidth = 0;
- JLabel var4 = new JLabel();
- ServiceDialog.access$300(var4, this, var2, var3);
- return var4;
- }
-
- public void actionPerformed(ActionEvent var1) {
- Object var2 = var1.getSource();
- if (var2 == this.btnProperties && this.uiFactory != null) {
- JDialog var3 = (JDialog)this.uiFactory.getUI(3, "javax.swing.JDialog");
- if (var3 != null) {
- var3.show();
- } else {
- this.btnProperties.setEnabled(false);
- }
- }
-
- }
-
- public void itemStateChanged(ItemEvent var1) {
- if (var1.getStateChange() == 1) {
- int var2 = this.cbName.getSelectedIndex();
- if (var2 >= 0 && var2 < ServiceDialog.access$500(this.this$0).length && !ServiceDialog.access$500(this.this$0)[var2].equals(ServiceDialog.access$400(this.this$0))) {
- ServiceDialog.access$402(this.this$0, ServiceDialog.access$500(this.this$0)[var2]);
- this.uiFactory = ServiceDialog.access$400(this.this$0).getServiceUIFactory();
- this.changedService = true;
- Destination var3 = (Destination)ServiceDialog.access$1100(this.this$0).get(Destination.class);
- if ((var3 != null || this.isPrintToFileSelected()) && ServiceDialog.access$400(this.this$0).isAttributeCategorySupported(Destination.class)) {
- if (var3 != null) {
- ServiceDialog.access$1200(this.this$0).add(var3);
- } else {
- var3 = (Destination)ServiceDialog.access$400(this.this$0).getDefaultAttributeValue(Destination.class);
- if (var3 == null) {
- try {
- var3 = new Destination(new URI("file:out.prn"));
- } catch (URISyntaxException var5) {
- }
- }
-
- if (var3 != null) {
- ServiceDialog.access$1200(this.this$0).add(var3);
- }
- }
- } else {
- ServiceDialog.access$1200(this.this$0).remove(Destination.class);
- }
- }
- }
-
- }
-
- public void popupMenuWillBecomeVisible(PopupMenuEvent var1) {
- this.changedService = false;
- }
-
- public void popupMenuWillBecomeInvisible(PopupMenuEvent var1) {
- if (this.changedService) {
- this.changedService = false;
- ServiceDialog.access$1300(this.this$0);
- }
-
- }
-
- public void popupMenuCanceled(PopupMenuEvent var1) {
- }
-
- private boolean allowedToPrintToFile() {
- try {
- this.throwPrintToFile();
- return true;
- } catch (SecurityException var2) {
- return false;
- }
- }
-
- private void throwPrintToFile() {
- SecurityManager var1 = System.getSecurityManager();
- if (var1 != null) {
- if (this.printToFilePermission == null) {
- this.printToFilePermission = new FilePermission("<<ALL FILES>>", "read,write");
- }
-
- var1.checkPermission(this.printToFilePermission);
- }
-
- }
-
- public void updateInfo() {
- Class var1 = Destination.class;
- boolean var2 = false;
- boolean var3 = false;
- boolean var4 = this.filePermission ? this.allowedToPrintToFile() : false;
- if (ServiceDialog.access$400(this.this$0).isAttributeCategorySupported(var1)) {
- var2 = true;
- }
-
- Destination var5 = (Destination)ServiceDialog.access$1200(this.this$0).get(var1);
- if (var5 != null) {
- var3 = true;
- }
-
- this.cbPrintToFile.setEnabled(var2 && var4);
- this.cbPrintToFile.setSelected(var3 && var4 && var2);
- PrintServiceAttribute var6 = ServiceDialog.access$400(this.this$0).getAttribute(PrinterMakeAndModel.class);
- if (var6 != null) {
- this.lblType.setText(var6.toString());
- }
-
- PrintServiceAttribute var7 = ServiceDialog.access$400(this.this$0).getAttribute(PrinterIsAcceptingJobs.class);
- if (var7 != null) {
- this.lblStatus.setText(ServiceDialog.getMsg(var7.toString()));
- }
-
- PrintServiceAttribute var8 = ServiceDialog.access$400(this.this$0).getAttribute(PrinterInfo.class);
- if (var8 != null) {
- this.lblInfo.setText(var8.toString());
- }
-
- this.btnProperties.setEnabled(this.uiFactory != null);
- }
- }
-